package system.company.JSP.TagClass;

import java.io.IOException;
import java.io.Serializable;

import javax.servlet.ServletException;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.TagSupport;

public class SessionValid extends TagSupport implements Serializable {

	private String name;
	private String page;
	public void setName(String name) {
		this.name = name;
	}
	public void setPage(String page) {
		this.page = page;
	}
	public SessionValid() {
		// TODO Auto-generated constructor stub
	}
	public int doStartTag() throws JspTagException {
		//Obtain variable
		Object ob = pageContext.getSession().getAttribute(name);
		try {
			if (ob == null) {
				pageContext.getServletContext().getRequestDispatcher(
					page).forward(
					pageContext.getRequest(),
					pageContext.getResponse());
			}
		} catch (IOException ioe) {
			throw new JspTagException(ioe.getMessage());
		} catch (ServletException se) {
			throw new JspTagException(se.getMessage());
		}
		return SKIP_PAGE;
	}

}
